<template>
  <div>
    <el-radio v-model="radio" :label="1">通过</el-radio>
    <el-radio v-model="radio" :label="2">拒绝</el-radio>
    <el-input
      style="margin-top:20px"
      type="textarea"
      :rows="3"
      placeholder="请输入内容"
      v-model="textarea">
    </el-input>
    <span slot="footer" class="dialog-footer">
      <el-button @click="hCancel">取 消</el-button>
      <el-button type="primary" @click="hSubmit">确 定</el-button>
    </span>
  </div>
</template>

<script>
import { choiceCheck } from '@/api/hmmm/questions'
export default {
  name: 'question-check',
  props: ['subID'],
  data () {
    return {
      radio: 1,
      textarea: ''
    }
  },
  methods: {
    hSubmit () {
      if ((this.textarea).trim() === '') {
        this.$message.warning('请输入审核意见')
        return
      }
      this.doSubCheck()
    },
    async doSubCheck () {
      const data = {
        id: this.subID,
        chkState: this.radio,
        chkRemarks: this.textarea
      }
      try {
        await choiceCheck(data)
        this.$message.success('操作成功')
        this.$emit('refresh')
        this.$emit('close')
      } catch (err) {
        this.$message.error('操作失败')
        console.log(err)
      }
    },
    hCancel () {
      this.$emit('close')
    }
  }
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
  .dialog-footer {
    display:block;
    text-align: right;
    margin-top: 30px;
  }
</style>
